<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>ErrorException</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="exception.clone.html">Exception::__clone</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="errorexception.construct.html">ErrorException::__construct</a></div>
 <div class="up"><a href="reserved.exceptions.html">预定义异常</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.errorexception" class="reference">
 <h1 class="title">ErrorException</h1>
 
 
 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.1.0)</p>
 

  <div class="section" id="errorexception.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    错误异常。
   </p>
  </div>

 
  <div class="section" id="errorexception.synopsis">
   <h2 class="title">类摘要</h2>
 

   <div class="classsynopsis">
    <div class="ooclass"></div>
 

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">ErrorException</strong>
     </span>
 
     <span class="ooclass">
      <span class="modifier">extends</span>
      <a href="class.exception.html" class="classname">Exception</a>
     </span>
     {</div>

 
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">protected</span>
     <span class="type">int</span>
      <var class="varname"><a href="class.errorexception.html#errorexception.props.severity">$<var class="varname">severity</var></a></var>
    ;</div>

 
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="errorexception.construct.html" class="methodname">__construct</a></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$message</code><span class="initializer"> = &quot;&quot;</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$code</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$severity</code><span class="initializer"> = 1</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code><span class="initializer"> = __FILE__</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$lineno</code><span class="initializer"> = __LINE__</span></span>
   [, <span class="methodparam"><span class="type"><a href="class.exception.html" class="type Exception">Exception</a></span> <code class="parameter">$previous</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]]]]]] )</div>

    <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="errorexception.getseverity.html" class="methodname">getSeverity</a></span>
    ( <span class="methodparam">void</span>
   )</div>

 
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">string</span><span class="methodname"><a href="exception.getmessage.html" class="methodname">Exception::getMessage</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">Exception</span><span class="methodname"><a href="exception.getprevious.html" class="methodname">Exception::getPrevious</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="exception.getcode.html" class="methodname">Exception::getCode</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">string</span><span class="methodname"><a href="exception.getfile.html" class="methodname">Exception::getFile</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="exception.getline.html" class="methodname">Exception::getLine</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">array</span><span class="methodname"><a href="exception.gettrace.html" class="methodname">Exception::getTrace</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type">string</span><span class="methodname"><a href="exception.gettraceasstring.html" class="methodname">Exception::getTraceAsString</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="exception.tostring.html" class="methodname">Exception::__toString</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">private</span> <span class="type">void</span><span class="methodname"><a href="exception.clone.html" class="methodname">Exception::__clone</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>

 
  </div>
 

  <div class="section" id="errorexception.props">
   <h2 class="title">属性</h2>
   <dl>

    
     <dt id="errorexception.props.severity"><var class="varname"><var class="varname">severity</var></var></dt>

     <dd>

      <p class="para">异常级别</p>
     </dd>

    
   </dl>

  </div>


  <div class="section" id="errorexception.examples">
   <h2 class="title">范例</h2>
   <p class="para">
    <div class="example" id="errorexception.example.error-handler">
     <p><strong>Example #1 使用<span class="function"><a href="function.set-error-handler.html" class="function">set_error_handler()</a></span>函数将错误信息托管至ErrorException</strong></p>
     <div class="example-contents">
 <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">exception_error_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errstr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errfile</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errline&nbsp;</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;</span><span style="color: #0000BB">ErrorException</span><span style="color: #007700">(</span><span style="color: #0000BB">$errstr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errfile</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errline</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">set_error_handler</span><span style="color: #007700">(</span><span style="color: #DD0000">"exception_error_handler"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Trigger&nbsp;exception&nbsp;*/<br /></span><span style="color: #0000BB">strpos</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <div class="example-contents"><p>以上例程的输出类似于：</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
Fatal error: Uncaught exception &#039;ErrorException&#039; with message &#039;Wrong parameter count for strpos()&#039; in /home/bjori/tmp/ex.php:8
Stack trace:
#0 [internal function]: exception_error_handler(2, &#039;Wrong parameter...&#039;, &#039;/home/bjori/php...&#039;, 8, Array)
#1 /home/bjori/php/cleandocs/test.php(8): strpos()
#2 {main}
  thrown in /home/bjori/tmp/ex.php on line 8
</pre></div>
     </div>
    </div>
   </p>
  </div>
 
 </div>
 
 



 



 





 



 
<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="errorexception.construct.html">ErrorException::__construct</a> — 异常构造函数</li><li><a href="errorexception.getseverity.html">ErrorException::getSeverity</a> — 获取异常的严重程度</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="exception.clone.html">Exception::__clone</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="errorexception.construct.html">ErrorException::__construct</a></div>
 <div class="up"><a href="reserved.exceptions.html">预定义异常</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
